<div class="row">
	<div class="col-md-12">
		<form id="iconAddForm" class="form-horizontal" action="${request.contextPath}/system/config/icon/add" method="post" onsubmit="return false">
			<div class="box-body" >
				<div class="form-group">
					<label id="iconClazzLabel" for="iconClazz" class="col-sm-1 control-label">样式类</label>
					<div class="col-sm-5">
						<input type="text" class="form-control" name="clazz" id="iconClazz" placeholder="输入样式类...">
					</div>
					<label id="iconSeqLabel" for="iconSeq" class="col-sm-1  control-label">排序号</label>
					<div class="col-sm-5">
						<input type="text" class="form-control" name="seq" id="iconSeq" type="number" placeholder="输入排序号...">
					</div>
				</div>
				<div class="form-group">
					<label id="iconWidthLabel" for="iconWidth" class="col-sm-1 control-label">宽度</label>
					<div class="col-sm-5">
						<input type="text" class="form-control" name="width" id="iconWidth" placeholder="输入宽度...">
					</div>
					<label id="iconHeightLabel" for="iconHeight" class="col-sm-1 control-label">高度</label>
					<div class="col-sm-5">
						<input type="text" class="form-control" name="height" id="iconHeight" placeholder="输入高度...">
					</div>
				</div>
				<div class="form-group">
					<label id="iconDescriptionLabel" class="col-sm-1 control-label" >描述</label>
					<div class="col-sm-11">
						<input type="text" class="form-control" name="description" id="iconDescription" placeholder="输入描述...">
					</div>
					</div>
				<div class="form-group">
					<label id="iconRemarkLabel" class="col-sm-1 control-label">备注</label>
					<div class="col-sm-11">
						<input type="text" class="form-control" name="remark" id="iconRemark" placeholder="输入备注...">
					</div>
				</div>
				<div class="error-message text-center" id="iconAddFormErrorMsgContainer">
					<span class="error-icon"></span>
					<span id="iconAddFormErrorMsg" class="error-msg" ></span>
				</div>
			</div>
			<div class="box-body">
				<div class="pull-right">
					<button type="submit" class="btn btn-primary btn-sm" ><i class="fa fa-save"></i> 保存</button>
					<button type="button" class="btn btn-default btn-sm" data-dismiss="modal"><i class="fa fa-close"></i> 取消</button>
				</div>
			</div>
		</form>
	</div>
</div>
<script type="text/javascript">
function ajaxSubmit(form) {
	
	var $form = $(form);
	
	if ($form.length === 1 && $form.validate()) {
		$.post(form.action, $form.serialize(),
			function(result) {
				if (result.success) {
					$("#lgModal").modal('hide');
		        	alertMsg(result.message,"success");
		        	iconReload();
				} else {
					$form.find(".error-msg").show();
					$form.find(".error-msg").html(result.message);
				}
			}, 'json');
	}
}

$(function() {
	 
	$iconAddForm = $("#iconAddForm");
	$iconAddForm.validate({
		rules: {
			clazz: {
				required: true
			},
            width: {
				required: true
			},
            height: {
				required: true
			},
			description: {
				required: true
			},
			seq: {
				required: true
			}
		},
		messages: {
            clazz:{
				required:"样式类不能为空！"
			},
            width:{
				required:"宽度不能为空！"
			},
            height:{
				required:"高度不能为空！"
			},
			description: {
				required: "描述不能为空！"
			},
			seq: {
				required: "排序号不能为空！"
			}
		},
		submitHandler:ajaxSubmit,
		errorLabelContainer:"#iconAddFormErrorMsgContainer",
		wrapper:"li",
		showErrors:function(errorMap,errorList) {
			if(errorList.length>0){
				$iconAddForm.find(".error-msg").html(errorList[0].message);
			}else{
				$iconAddForm.find(".error-msg").html("");
			}
		},
		onkeyup: false
	});
});
</script>